<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="top">
        Manage Accounts
    </ui:define>

    <ui:define name="left">
    </ui:define>



    <ui:define name="body">
        <h:form>
            <h:outputLabel value="User Search:"/>
            <h:inputText value="#{userCTRL.user2Search}"/>
            <h:commandButton value="Search" action="#{userCTRL.search}"/>
            <h:commandLink value="View all users" action="#{userCTRL.manageAccountsPrep}" rendered="#{userCTRL.viewingSearchResults}"/>
            <br/>
            <h:dataTable width="100%" rendered="#{userCTRL.userList.rowCount != -1}" value="#{userCTRL.userList}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="User"/>
                    </f:facet>
                    <c:choose>
                        <c:when test="#{item.isAdmin}">
                            <h:outputText style="color: red" value="#{item.login}"/>
                        </c:when>
                        <c:otherwise>
                            <h:outputText value="#{item.login}"/>
                        </c:otherwise>
                    </c:choose>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value=" "/>
                    </f:facet>
                    <h:commandButton action="#{userCTRL.promoteUser}" value="Promote"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value=" "/>
                    </f:facet>
                    <h:commandButton action="#{userCTRL.demoteUser}" value="Demote"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value=" "/>
                    </f:facet>
                    <h:commandButton action="#{userCTRL.deleteAnotherUser}" value="Delete"/>
                </h:column>
            </h:dataTable>
        </h:form>
    </ui:define>

</ui:composition>
